from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.schedulers.background import BackgroundScheduler
import time
"""
主程序继续执行，任务挂后台运行
"""


def task_a(x, y, email=''):
    print(f"hello world---{x}---{y}----{email}")


def task_b(name='', age=0):
    print(f"第2个任务----{name}-----{age}")


scheduler = BackgroundScheduler()
scheduler.add_job(task_a,
                  args=('aaa', 'bbb'),
                  kwargs={"email": "222@qq.com"},
                  trigger='interval',
                  id='task1',
                  seconds=3
                  )
scheduler.add_job(task_b,
                  kwargs={"name": "yoyo", "age": 22},
                  trigger='interval',
                  id='task2',
                  seconds=6
                  )
scheduler.start()


# 主程序执行
while True:
    time.sleep(2)
    print(f"当前时间： {time.time()}")